#ifndef INAREA_H
#define INAREA_H

// ATENTION:
// * Overlap of areas are ignored. If a pint exists in more than one area, only
//   one of them will be used. There is no warranty on which area will be used.
// * No area should be removed after it has been pressed but is yet to be
//   released. If such isn't done, unpredictable behavior may occur.
// * No verifications against bad usage are done.

//******************************************************************************
// Error Codes

#define INAREA_ERROR_NO_IDS_AVAILABLE -1

//******************************************************************************
// Types

// defines an area's id
typedef int inarea_id_t;

// defines a rectangle
typedef struct
{
    // top left corner
    unsigned int x;
    unsigned int y;
    // dimensions
    unsigned int width;
    unsigned int height;
} inarea_rect_t;

// defines a signature for the handlers
typedef void (*inarea_callback_t) (inarea_rect_t*);

//******************************************************************************
// Functions

// if possible, adds an area; if not, returns an illegal id
inarea_id_t // area's id or an error code
TSD_InareaAdd (inarea_callback_t, // pressed callback, may be 0
        inarea_callback_t, // moved out callback, may be 0
        inarea_callback_t, // released callback, may be 0
        inarea_rect_t*, // rectangles that define the area, shouldn't be 0
        int); // number of rectangles, should be bigger then 0

// removes the chosen area
void TSD_InareaRemove (inarea_id_t);

// removes all areas
void TSD_InareaRemoveAll (void);

//******************************************************************************
#endif /* INAREA_H */
